package com.smile.controller;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smile.commons.page.MyBatisPlusPageConverter;
import com.smile.commons.page.R;
import com.smile.model.dto.request.*;
import com.smile.model.response.response.GetAirportByIdResponseDTO;
import com.smile.model.response.response.GetAirportInfoResponseDTO;
import com.smile.model.response.response.GetAirportListResponseDTO;
import com.smile.model.request.*;
import com.smile.model.response.Drone;
import com.smile.model.response.GetAirportByIdResponse;
import com.smile.model.response.GetAirportListResponse;
import com.smile.service.AirportInfoService;
import com.smile.service.AirportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.io.IOException;

@RestController
@RequestMapping("/airportinfo")
public class AirportInfoController {

    @Autowired
    private AirportInfoService  airportInfoService;

    @PostMapping("/getAirportInfoById")
    public R<GetAirportInfoResponseDTO> getAirportInfoById(@RequestBody GetAirportInfoByIdRequest  getAirportByIdRequest) {
        GetAirportInfoRequestDTO getAirportInfoRequestDTO = BeanUtil.copyProperties(getAirportByIdRequest, GetAirportInfoRequestDTO.class);
        GetAirportInfoResponseDTO getAirportInfoResponseDTO = airportInfoService.getAirportInfoById(getAirportInfoRequestDTO);
        return R.ok(getAirportInfoResponseDTO);
    }

    @PostMapping("/getAirportInfoById2")
    public R<GetAirportInfoResponseDTO> getAirportInfoById2(@RequestBody GetAirportInfoByIdRequest  getAirportByIdRequest) {
        GetAirportInfoRequestDTO getAirportInfoRequestDTO = BeanUtil.copyProperties(getAirportByIdRequest, GetAirportInfoRequestDTO.class);
        GetAirportInfoResponseDTO getAirportInfoResponseDTO = airportInfoService.getAirportInfoById(getAirportInfoRequestDTO);
        return R.ok(getAirportInfoResponseDTO);
    }
}
